package org.gatech.linalg;

public class MatrixTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Matrix m1,m2;
		try{
//			double[][] testVals = {{5,0,0},{0,3,0},{0,0,0}};
//			m1 = new Matrix(testVals);
//			System.out.println(m1 + "\n");
//			System.out.println(Matrix.inverse(m1));
			
//			double[][] testVals = {{3,5,6},{2,6,2},{8,7,2}};
//			double[][] testVals2 = {{1,1,1},{1,1,1},{1,1,1}};
//			m1 = new Matrix(testVals);
//			m2 = new Matrix(testVals2);
//			System.out.println(m1 + "\n");
//			System.out.println(m2 + "\n");
//			System.out.println(Matrix.product(m1, m2) + "\n");

//			double[][] testVals = {{1},{3},{5}};
//			double[][] testVals2 = {{2},{4},{6}};
//			m1 = new Matrix(testVals);
//			m2 = new Matrix(testVals2);
//			System.out.println(m1 + "\n");
//			System.out.println(m2 + "\n");
//			System.out.println(Matrix.dot(m1, m2) + "\n");
//			System.out.println(Matrix.augment(m1, m2) + "\n");
//			System.out.println(Matrix.augment(m1, Matrix.makeIdentity(3)));
			
//			double[][] testVals = {{1,1,2},{2,4,-3},{3,6,-5}};
//			m1 = new Matrix(testVals);
//			System.out.println(m1 + "\n");
//			System.out.println(Matrix.inverse(m1) + "\n");
			
//			double[][] testVals = {{1,2,-2},{-2,-2,5},{-3,-2,7}};
//			m1 = new Matrix(testVals);
//			System.out.println(m1 + "\n");
//			Matrix[] LU = Matrix.LUDecomposition(m1);
//			System.out.println(LU[0] + "\n");
//			System.out.println(LU[1] + "\n");
//			System.out.println(Matrix.product(LU[0], LU[1]));
			
//			double[][] b = {{-5},{0},{-2}};
//			
//			Matrix augmented = Matrix.augment(m1, new Matrix(b));
//			System.out.println(augmented + "\n");
//			System.out.println(Matrix.rref(augmented) + "\n");
//			
//			System.out.println(Matrix.solve(m1, new Matrix(b)));
			
			double[][] testVals = {{1,2,3},{4,5,6},{7,8,9}};
//			double[][] testVals = {{3,2,4},{2,0,2},{4,2,3}};
			m1 = new Matrix(testVals);
			Matrix [] Q = Matrix.QRIteration(m1,1e-8);
			System.out.println(Q[0]);
			System.out.println(Q[1]);
			
//			m1 = Matrix.product(m1, Matrix.transpose(m1));
//			System.out.println(m1 + "\n");
//			double[] eigs = Matrix.eig(m1, 1e-8);
//			for(int i = 0; i < eigs.length; i++)
//				System.out.println(eigs[i]);
//			System.out.println("\n");
//			System.out.println(Matrix.eigenVectors(m1, 1e-8));
			
//			double[][] testVals1 = {{1,2},{3,4}};
//			double[][] testVals2 = {{5,6},{7,8}};
//			m1 = new Matrix(testVals1);
//			m2 = new Matrix(testVals2);
//			System.out.println(Matrix.product(m1, m2));
			
//			double[][] testVals = {{4,4},{-3,3}};
//			double[][] testVals = {{3,2,2},{2,3,-2}};
//			double[][] testVals = {{2,4},{1,3}};
//			double[][] testVals = {{1,2,3},{4,5,6},{7,8,9}};
//			m1 = new Matrix(testVals);
//			System.out.println(m1 + "\n");
//			Matrix[] svd = Matrix.SVD(m1);
//
//			System.out.println(svd[0] + "\n\n");
//			System.out.println(svd[1] + "\n\n");
//			
//			System.out.println(svd[2] + "\n\n");
//			System.out.println(Matrix.product(svd[0], Matrix.product(svd[1], Matrix.transpose(svd[2]))));
			
			System.out.println("");
		}
		catch(DimensionMismatchException e){
			e.printStackTrace();
		}
//		catch(NonInvertibleException nie){
//			nie.printStackTrace();
//		}
//		catch(IOException e){
//			e.printStackTrace();
//			System.err.println(e.getMessage());
//		}
//			e.printStackTrace();
//		}
		finally{
			
		}
	}

}
